package com.ybg.util;

/**
 * 奕报告全局异常类
 * 
 * @author ningjh
 * @since  2016-07-19
 */
public class YbgException extends RuntimeException {
	private static final long serialVersionUID = -2585865362014659507L;
	
	/** 错误代码 */
	private String errorCode;
	
	/** 自定义日志信息 */
	private String custom;
	
	/** 异常数据 */
	private String data;
	
	public YbgException() {
		this("0001", ""); // system error
	}
	
	public YbgException(String errorCode) {
		this(errorCode, "");
	}
	
	public YbgException(String errorCode, String custom) {
		this(errorCode, custom, null);
	}
	
	public YbgException(String errorCode, Throwable cause) {
		this(errorCode, "", cause);
	}
	
	public YbgException(String errorCode, String custom, Throwable cause) {
		super(ConfigUtil.getString(ConfigUtil.ERROR_PREFIX + errorCode, "system error"), cause);
		this.errorCode = errorCode;
		this.custom    = custom;
		this.data = "";
	}
	
	public YbgException(Throwable cause) {
		this("0001", "", cause);
	}

	public String getErrorCode() {
		return errorCode;
	}

	public String getCustom() {
		return custom;
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		if(data != null) this.data = data;
	}
}
